package com.hr.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.hr.domain.po.PaymentRecord;
import com.hr.domain.query.PaymentRecordPageParams;
import com.hr.domain.query.PaymentRecordPageResult;
import com.hr.domain.vo.PaymentRecordVO;
import com.hr.service.PaymentRecordService;
import com.hr.mapper.PaymentRecordMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 86150
* @description 针对表【payment_record(支付记录表)】的数据库操作Service实现
* @createDate 2025-09-30 08:42:36
*/
@Service
@AllArgsConstructor
public class PaymentRecordServiceImpl implements PaymentRecordService{

    private final PaymentRecordMapper paymentRecordMapper;

    /**
     * 分页获取支付记录列表
     * @return paymentRecordPageResult
     */
    @Override
    public PaymentRecordPageResult getPaymentRecordPageList(PaymentRecordPageParams queryParams) {
        //开始分页
        PageHelper.startPage(queryParams.getPageNum(), queryParams.getPageSize());
        //传递分页参数
        List<PaymentRecordVO> paymentRecordList = paymentRecordMapper.getPaymentRecordPageList(queryParams);
        //强转为Page<PaymentRecordVO>
        Page<PaymentRecordVO> page = (Page<PaymentRecordVO>) paymentRecordList;
        //返回
        return new PaymentRecordPageResult(page.getTotal(), page.getResult());
    }

    @Override
    public String updatePaymentRecordStatus(Long id, Integer status) {
        int row = paymentRecordMapper.updatePaymentRecordStatus(id, status);
        return row > 0 ? "更新状态成功" : "更新状态失败";
    }
}




